time issue in render libgdx [duplicate]
Posted
by
jaysingh
on Game Development
See other posts from Game Development
or by jaysingh
Published on 2013-11-03T19:59:16Z
Indexed on
2013/11/03
22:20 UTC
Read the original article
Hit count: 280
libgdx
This question is an exact duplicate of:
pls. help how to implement this loop in render method next_game_tick and GetTickCount(); always contain same time value so player position not updated.
@Override
public void render()
{
float deltaTime = Gdx.graphics.getDeltaTime();
Update(deltaTime);
Render(deltaTime);
}
const int TICKS_PER_SECOND = 50;
const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
const int MAX_FRAMESKIP = 10;
DWORD next_game_tick = GetTickCount();
int loops;
bool game_is_running = true;
while( game_is_running ) {
loops = 0;
while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) {
update_game();
next_game_tick += SKIP_TICKS;
loops++;
}
display_game();
}
© Game Development or respective owner